/**
 * Copyright European Commission's
 * Taxation and Customs Union Directorate-General (DG TAXUD).
 */
package com.eryos.bean;

import java.util.ArrayList;
import java.util.List;

import com.eryos.Constants;

public class City {
    private int id;
    private String name;
    private int nbResult;
    private int nbResultToday = 0;
    private List<Result> listOfResult = new ArrayList<Result>();
    private List<Result> listOfResultToday = new ArrayList<Result>();

    public String getSummary(boolean today) {
        String summary = "<li><a href=\"#city_" + getId() + "\">" + getName() + " (";
        if (today) {
            summary += listOfResultToday.size();
        } else {
            summary += listOfResult.size();
        }
        return summary + " results)</a></li>";
    }

    public String getTitle(boolean today) {
        String title = "<hr><h3><a id=\"city_" + getId() + "\">" + getName() + " (";
        if (today) {
            title += listOfResultToday.size();
        } else {
            title += listOfResult.size();
        }
        return title + " results) </a> <a href=\"#top\">Haut</a> <a href=\"https://maps.google.com/?q=" + getName()
                + "\">Plan</a></h3>";
    }

    public City(int id, String name) {
        this.id = id;
        this.name = name;
        listOfResult = new ArrayList<Result>();
    }

    public void addResult(Result result) {
        listOfResult.add(result);
        if (result.getDate().startsWith(Constants.AUJOURD_HUI)) {
            listOfResultToday.add(result);
            nbResultToday++;
        }
    }

    /**
     * @return the listOfResult
     */
    public List<Result> getListOfResult() {
        return listOfResult;
    }

    /**
     * Sets the listOfResult.
     * 
     * @param listOfResult
     *            the value to set
     */
    public void setListOfResult(List<Result> listOfResult) {
        this.listOfResult = listOfResult;
    }

    /**
     * @return the id
     */
    public int getId() {
        return id;
    }

    /**
     * Sets the id.
     * 
     * @param id
     *            the value to set
     */
    public void setId(int id) {
        this.id = id;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * Sets the name.
     * 
     * @param name
     *            the value to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * Sets the nbResult.
     * 
     * @param nbResult
     *            the value to set
     */
    public void setNbResult(int nbResult) {
        this.nbResult = nbResult;
    }

    @Override
    public String toString() {
        return getName() + " : " + listOfResult.size();
    }

    /**
     * @return the listOfResultToday
     */
    public List<Result> getListOfResultToday() {
        return listOfResultToday;
    }

    /**
     * Sets the listOfResultToday.
     * 
     * @param listOfResultToday
     *            the value to set
     */
    public void setListOfResultToday(List<Result> listOfResultToday) {
        this.listOfResultToday = listOfResultToday;
    }

}
